package LogicaClasesNew;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.Endpoint;

@WebService
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class WsIlineaOrden {
  
    private Endpoint endpoint = null;
    private IcontroladorLineaOrden ICL;

    
    //Constructor que publica el WebService con sus metodos.
    public WsIlineaOrden() {
        
    Fabrica fabrica = Fabrica.getInstance();
    this.ICL = fabrica.getControladorLineaOrden();
    try{
    Properties preferences = new Properties();
    FileInputStream in = new FileInputStream(System.getProperty("user.home")+"/configWebServices.ini");
    preferences.load(in);
    String host = preferences.getProperty("Host");
    String port = preferences.getProperty("Port");
    endpoint = Endpoint.publish("http://"+host+":"+port+"/ilineorden", this);
    }
    catch(Exception ex){
    //    endpoint = Endpoint.publish("http://localhost:8280/ilineorden", this);
    }


		
//.....WebMethod.....
    }
    @WebMethod
    public void createLineaOrden(int cantidad, float precioactual, int NumRefProd){
        ICL.createLineaOrden(cantidad, precioactual, NumRefProd);
    }
    
    @WebMethod
    public int IntcreateLineaOrden(int cantidad, float precioactual, int NumRefProd){
        return ICL.IntcreateLineaOrden(cantidad, precioactual, NumRefProd);
    }
    
    @WebMethod
    public ArrayList<LineaOrden> findLineaOrdenEntities(){
        return new ArrayList(ICL.findLineaOrdenEntities());
    }
    
    @WebMethod
    public LineaOrden findLineaOrden(int id){
        return ICL.findLineaOrden(id);
    }
   
    @WebMethod(exclude = true)
	public Endpoint getEndpoint() {
            return endpoint;
    }
    
}



